package com.meidusa.amoeba.mysql.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class SysLimit {
		public static int tableRow =  Integer.valueOf(getProperties("table.row"));
		public static int maxTableNum =  Integer.valueOf(getProperties("max.table"));
		public static int maxSortRow =  Integer.valueOf(getProperties("max.sort.row"));
		public static int maxNoIndexRow =  Integer.valueOf(getProperties("max.no.index.row"));
		public static int maxQueryRow =  Integer.valueOf(getProperties("max.query.row"));
		public static int maxUpdateRow =  Integer.valueOf(getProperties("max.update.row"));
		public static int maxDeleteRow =  Integer.valueOf(getProperties("max.delete.row"));
		public static int maxCreateIndexRow =  Integer.valueOf(getProperties("max.create.index.row"));
		public static int maxAlterIndexRow =  Integer.valueOf(getProperties("max.alter.index.row"));
		public static String MEMCACHEDADDR =  getProperties("memcached.addr");
		
	
	
	@SuppressWarnings("static-access")
	static String getProperties(String key) {
		Properties p = new Properties();
		InputStream inputStream = null;
		String rs = null;
		try {
			inputStream = new FileInputStream(new java.net.URLDecoder().decode(SysLimit.class.getClassLoader()  
					.getResource("config.properties").getPath(),"utf-8"));
			p.load(inputStream);
			rs = p.getProperty(key);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
		}finally{
			p.clone();
			try {
				inputStream.close();
			} catch (IOException e) {
			}
		}
		return rs;
		
	}
}

